package com.weasel.weixin.commons.message;

import com.weasel.weixin.commons.message.bean.WeixinPostEventXmlMessage;
import com.weasel.weixin.commons.message.handler.AbstractWeixinPostEventXmlMessageHandler;

import java.util.LinkedList;
import java.util.List;

/**
 * Created by Dylan on 2015/10/9.
 */
public class WeixinPostEventXmlMessageHandlerRouter {

    private final List<AbstractWeixinPostEventXmlMessageHandler> handlers = new LinkedList<>();

    private final WeixinPostEventXmlMessage message;


    public WeixinPostEventXmlMessageHandlerRouter(WeixinPostEventXmlMessage message) {
        this.message = message;
    }

    public WeixinPostEventXmlMessageHandlerRouter addHandler(AbstractWeixinPostEventXmlMessageHandler handler){

        handlers.add(handler);
        return this;
    }

    public void handler(){
        for (AbstractWeixinPostEventXmlMessageHandler handler : handlers){
            handler.doHandler(message);
        }
    }

}
